<template>
	<q-table ref="commonTable" :config="tableConfig" />
</template>
<script setup lang="ts">
	import { ref, reactive } from 'vue';
	import $dateFormat from '@q-admin-design-vue/utils/DateFormat';
	// mock列表数据
	const tableList = {
		code: '',
		data: {
			blackNameUploadRecords: [
				{
					admitPerson: '管理员',
					auditLevelCode: 'FIRST_AUDIT_CODE',
					auditRole: 'absm_sample_data_list',
					batchNo: '09fce7b79ec540f1a81c17047f3af8e2',
					busiCode: 'DUOLA_JOIN_BLACK_NAME',
					exportDate: 1669018754000,
					nameNum: 3,
					remarkInfo: '回归测试',
					status: 'AT_PAS',
					submitDate: 1669018770000,
					submitPerson: '管理员',
				},
				{
					admitPerson: '管理员',
					auditLevelCode: 'FIRST_AUDIT_CODE',
					auditRole: 'absm_sample_data_list',
					batchNo: '5b67f739ef9a4cd6be7f2bdfd030d7a7',
					busiCode: 'DUOLA_JOIN_BLACK_NAME',
					exportDate: 1668674777000,
					nameNum: 5000,
					remarkInfo: 'null',
					status: 'AT_PAS',
					submitDate: 1668674812000,
					submitPerson: '管理员',
				},
				{
					admitPerson: '管理员',
					auditLevelCode: 'FIRST_AUDIT_CODE',
					auditRole: 'absm_sample_data_list',
					batchNo: '63f36f679bf74920806c1a7289881e2d',
					busiCode: 'DUOLA_JOIN_BLACK_NAME',
					exportDate: 1668674752000,
					nameNum: 5000,
					remarkInfo: 'null',
					status: 'AT_RJT',
					submitDate: null,
					submitPerson: '管理员',
				},
				{
					admitPerson: '',
					auditLevelCode: 'FIRST_AUDIT_CODE',
					auditRole: 'absm_sample_data_list',
					batchNo: '6a48fd9ed8cc405595a5933303f17c76',
					busiCode: 'DUOLA_JOIN_BLACK_NAME',
					exportDate: 1668674729000,
					nameNum: 5000,
					remarkInfo: 'null',
					status: 'AT_CCL',
					submitDate: null,
					submitPerson: '管理员',
				},
				{
					admitPerson: '管理员',
					auditLevelCode: 'FIRST_AUDIT_CODE',
					auditRole: 'absm_sample_data_list',
					batchNo: 'c71bfa2b46ba405f8246dfa380c4273c',
					busiCode: 'DUOLA_JOIN_BLACK_NAME',
					exportDate: 1668673987000,
					nameNum: 6,
					remarkInfo: 'null',
					status: 'AT_PAS',
					submitDate: 1668673994000,
					submitPerson: '管理员',
				},
				{
					admitPerson: '管理员',
					auditLevelCode: 'FIRST_AUDIT_CODE',
					auditRole: 'absm_sample_data_list',
					batchNo: '8855ecee4abe44459e3b15f68906472c',
					busiCode: 'DUOLA_REMOVE_BLACK_NAME',
					exportDate: 1668673817000,
					nameNum: 6,
					remarkInfo: 'null',
					status: 'AT_PAS',
					submitDate: 1668673834000,
					submitPerson: '管理员',
				},
				{
					admitPerson: '管理员',
					auditLevelCode: 'FIRST_AUDIT_CODE',
					auditRole: 'absm_sample_data_list',
					batchNo: 'ca3134b72b9c4bc88658c40204bf5448',
					busiCode: 'DUOLA_JOIN_BLACK_NAME',
					exportDate: 1668649353000,
					nameNum: 4999,
					remarkInfo: '上限测试',
					status: 'AT_PAS',
					submitDate: 1668649406000,
					submitPerson: '管理员',
				},
				{
					admitPerson: '',
					auditLevelCode: 'FIRST_AUDIT_CODE',
					auditRole: 'absm_sample_data_list',
					batchNo: '79baecc8664b41a5b3ab38293a553432',
					busiCode: 'DUOLA_JOIN_BLACK_NAME',
					exportDate: 1668491049000,
					nameNum: 3,
					remarkInfo: 'null',
					status: 'W_AT',
					submitDate: null,
					submitPerson: '管理员',
				},
				{
					admitPerson: '管理员',
					auditLevelCode: 'FIRST_AUDIT_CODE',
					auditRole: 'absm_sample_data_list',
					batchNo: '7784ae0104ed4b32a483484e4957634e',
					busiCode: 'DUOLA_JOIN_BLACK_NAME',
					exportDate: 1668483234000,
					nameNum: 3,
					remarkInfo: '反反复复',
					status: 'AT_RJT',
					submitDate: null,
					submitPerson: '管理员',
				},
				{
					admitPerson: '',
					auditLevelCode: 'FIRST_AUDIT_CODE',
					auditRole: 'absm_sample_data_list',
					batchNo: '8d7237618be04df3aee39b48ed7cc171',
					busiCode: 'DUOLA_JOIN_BLACK_NAME',
					exportDate: 1668483107000,
					nameNum: 3,
					remarkInfo: '审核流程测试',
					status: 'AT_CCL',
					submitDate: null,
					submitPerson: '管理员',
				},
			],
			count: 46,
			isNext: '',
			pageNo: 1,
			pageNum: 5,
			pageSize: 10,
		},
		flag: 'S',
		msg: '',
	};
	// table项配置
	const tableColumns = [
		{
			title: '备注',
			field: 'remarkInfo',
			align: 'center',
			overflowTooltipLimit: 4,
		},
		{
			title: '当前状态',
			field: 'status',
			align: 'center',
			formatter: value => {
				return value === 'DRAFT'
					? '待提审'
					: value === 'W_AT'
					? '待审核'
					: value === 'AT_RJT'
					? '驳回'
					: value === 'AT_PAS'
					? '已完成'
					: value === 'AT_CCL'
					? '审核撤销'
					: '-';
			},
		},
		{
			title: '名单导入时间',
			field: 'exportDate',
			align: 'center',
			width: 120,
			formatter: value => {
				return value ? $dateFormat.YYYYMMDDHHmmss(value, '-') : '-';
			},
		},
	];

	const tableConfig = reactive({
		searchParams: {},
		reqApiMethod: () => {
			return new Promise(resolve => {
				resolve(tableList);
			});
		},
		responseHandler: payload => {
			return {
				records: payload?.blackNameUploadRecords || [],
				total: payload?.count || 0,
			};
		},
		columns: tableColumns,
	});
</script>
<style lang="scss">
	/**使用组件时 该样式无需复制 仅用做调整 受vitepress框架影响的样式 */
	.common-table-wrapper {
		.el-table--fit {
			margin-top: 20px !important;
		}
		.el-table-column--selection {
			padding-left: 14px !important;
		}
		.q-overflow-tooltip-wrapper {
		}
	}
	.vp-doc p,
	.vp-doc summary {
		margin: 0 !important;
	}
</style>
